package utils

import (
	"encoding/json"
	"fmt"
)

//map转 struct  out ModeDto
func MapToStruct(maps map[interface{}]interface{}, modelDto interface{}) {
	arr, err := json.Marshal(maps)
	err = json.Unmarshal(arr, &modelDto)
	if err != nil {
		fmt.Println("maps转struct失败!", err)
		return
	}
	fmt.Println(fmt.Sprintf(`当前maps值：%s  当前struct %v`, maps, modelDto))
}

//Json To struct  out struct
func JsonToStruct(str []byte, modelDto interface{}) {
	err := json.Unmarshal(str, modelDto)
	if err != nil {
		fmt.Println("err", err)
		return
	}
	fmt.Println(`当前struct`, modelDto)

}
